<?php
/**
 * This is used in partialLoop helper views to store data throughout the life of the loop
 */
class ImpSoft_View_Helper_PartialLoopStorage {

	/**
	 * This is the default namespace used for storage.
	 */
	protected $namespace = 'default';
	/**
	 * This is the array that all the data is stored in
	 */
	protected $storage = array();
	/**
	 * An accessor method, calling it with just namespace (or no arguments) will return the value
	 * for that namespace. If you provide the second argument, $value, it will set that value on $namespace
	 * Actually, either way it returns data for the specified data namespace
	 */
    public function partialLoopStorage($namespace = null) {
    
    	if (is_null($namespace)) $namespace = $this->namespace;
        $args = args();
        if (isset($args[1])) {
        	$value = $args[1];
        	$this->storage[$namespace] = $value;
        }
        if (isset($this->storage[$namespace])) return $this->storage[$namespace];
        return '';
    
    }
    
    public function setView($view) {
        $this->view = $view;
    }

}